/*河南星辰软件科技有限公司
@copyright Copyright (c) 2010~2022 All rights reserved.
*/
package cn.javaxc.crm.action.sale.potential;
import java.io.*;
import java.util.*;
import java.sql.*;
import cn.javaxc.model.base.SQL;
import cn.javaxc.model.base.SQLList;
import cn.javaxc.model.base.SQLMap;
import cn.javaxc.model.base.SQLParam;
import cn.javaxc.model.page.BatisPage;
import cn.javaxc.mvcwork.controller.web.TreeBean;
import cn.javaxc.mvcwork.util.common.CommonUtil;
import cn.javaxc.mvcwork.util.common.MapListUtil;
import cn.javaxc.mvcwork.util.helper.FrameHelper;
import cn.javaxc.mvcwork.util.helper.TreeTableHelper;
import org.springframework.beans.factory.annotation.Autowired;
import cn.javaxc.system.action.base.BaseAction;
import cn.javaxc.crm.mapper.sale.potential.CustomerAddMapper;
public class CustomerAdd extends BaseAction
{
    @Autowired(required=false)
	private CustomerAddMapper mapper;
    /**
    增加潜在商户
    */
    
    public Map customerAdd() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> clientorigin=mapper.clientorigin(params);
        result.put("clientorigin", clientorigin);
        
        
        
        
        SQLList<SQLMap> clientbus=mapper.clientbus(params);
        result.put("clientbus", clientbus);
        
        
        result.put("client_message", create_code(9,"client_barcode"));
        
        
        
        
        result.putAll(communicationPubPage());
        
        return result;
    }
    /**
    增加电话等公用页面
    */
    
    public Map communicationPubPage() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> add_phone=mapper.add_phone(params);
        result.put("add_phone", add_phone);
        
        
        result.put("s_mail", add_phone);
        
        
        result.put("s_moment", add_phone);
        
        
        SQLList<SQLMap> clienttype=mapper.clienttype(params);
        result.put("clienttype", clienttype);
        
        
        SQLList<SQLMap> clientmode=mapper.clientmode(params);
        result.put("clientmode", clientmode);
        
        
        SQLList<SQLMap> clientrate=mapper.clientrate(params);
        result.put("clientrate", clientrate);
        
        
        SQLList<SQLMap> phonetype=mapper.phonetype(params);
        phonetype.setSelectNone("请选择");
        result.put("phonetype", phonetype);
        
        
        SQLList<SQLMap> emailtype=mapper.emailtype(params);
        emailtype.setSelectNone("请选择");
        result.put("emailtype", emailtype);
        
        
        SQLList<SQLMap> momentcon=mapper.momentcon(params);
        momentcon.setSelectNone("请选择");
        result.put("momentcon", momentcon);
        
        
        SQLList<SQLMap> momentconano=mapper.momentconano(params);
        momentconano.setSelectNone("选择方式");
        result.put("momentconano", momentconano);
        
        
        SQLList<SQLMap> s_province=mapper.s_province(params);
        result.put("s_province", s_province);
        
        return result;
    }
    /**
    选择省
    */
    
    public Map potentialProvinceChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_province=mapper.s_province(params);
        result.put("s_province", s_province);
        
        return result;
    }
    /**
    选择市
    */
    
    public Map potentialCityChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_province=mapper.s_province(params);
        result.put("s_province", s_province);
        
        return result;
    }
    /**
    选择县
    */
    
    public Map potentialCountyChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_province=mapper.s_province(params);
        result.put("s_province", s_province);
        
        return result;
    }
    /**
    选择邮政编码
    */
    
    public Map potentialPostcodeChoice() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        SQLList<SQLMap> s_province=mapper.s_province(params);
        result.put("s_province", s_province);
        
        return result;
    }
    /**
    增加潜在商户修改
    */
    
    public Map customerAddSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        int CMID = mapper.CMID(params);
        result.put("CMID", CMID);
        
        
        int CMID2 = mapper.CMID2(params);
        result.put("CMID2", CMID2);
        
        return result;
    }
    /**
    增加电话等公用页面修改
    */
    
    public Map communicationPubPageSubmit() {
        
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        int address = mapper.address(params);
        result.put("address", address);
        
        
        for (SQLMap emt:hqlBean.getTableElements("phones")){
            params=new SQLParam(request,emt.getMap());
            mapper.ph_id(params);
        }
        
        
        for (SQLMap emt:hqlBean.getTableElements("email")){
            params=new SQLParam(request,emt.getMap());
            mapper.em_id(params);
        }
        
        
        for (SQLMap emt:hqlBean.getTableElements("moment_contact")){
            params=new SQLParam(request,emt.getMap());
            mapper.b_moment_contact(params);
        }
        
        
        for (SQLMap emt:hqlBean.getTableElements("phones")){
            params=new SQLParam(request,emt.getMap());
            mapper.ph_id(params);
        }
        
        
        for (SQLMap emt:hqlBean.getTableElements("email")){
            params=new SQLParam(request,emt.getMap());
            mapper.em_id(params);
        }
        
        
        for (SQLMap emt:hqlBean.getTableElements("moment_contact")){
            params=new SQLParam(request,emt.getMap());
            mapper.b_moment_contact(params);
        }
        
        
        int i_address = mapper.i_address(params);
        result.put("i_address", i_address);
        
        return result;
    }
    public Map ajaxList(){
        String sql="";
        String pagesql="";
        Map result=new HashMap();
        SQLParam params=new SQLParam(request,result);
        
        if(request.getParameter("cfield_name").contains("address_city")){
            SQLList<SQLMap> address_city=mapper.address_city(params);
            result.put("address_city", address_city);
        }
        
        
        if(request.getParameter("cfield_name").contains("address_town")){
            params.def("address_city",-1);
            SQLList<SQLMap> address_town=mapper.address_town(params);
            result.put("address_town", address_town);
        }
        
        return result;
    }
}